<?php	include_once('inc/header.php');
		include_once('inc/product.inc.php'); ?>
	

	<!--page-->
	<div id="banner">
		<div class="container intro_wrapper">
			<div class="inner_content">
			<?php 
				if(isset($user) && isset($_GET['op']) && $_GET['op'] == "proceed")
				{
					echo '<h2 style="text-transform: uppercase">Ongoing process</h2>
					<h1 class="title" style="text-transform: uppercase">Checkout</h1>
					
					<h3>
						<div id="desc">Your order of <span class="hue">'.getInfosCart(0, "itemsQuantity").' products</span>
						 has been <span>successfully</span> registered.</br>Please follow the steps to proceed now to the <span>payment</span>.</div>
					</h3>
					';
				}
				else
				{
					echo '<h2 style="text-transform: uppercase">Unreachable request</h2>
					<h1 class="title" style="text-transform: uppercase">Oops</h1>
					
					<h3>
						<div id="desc">You can\'t access this section for the now. <span>Fill</span> your cart and <span class="hue">proceed to checkout</span> later!</div>
					</h3>
					';
				}
			?>
			</div>
		</div>
	</div>
		
		
	<div class="container wrapper" id="containerWrapper" style="padding-bottom:0px">
		<div class="inner_content">
	
	<?php
	
	/*  We start the checkout process:
		1) The order is stored in the database
		2) Payment operation begins (Not implemented for the now) 
	*/
	if(isset($user) && isset($_GET['op']) && $_GET['op'] == "proceed")
	{	
		$length = count($_SESSION['cart']['pr_id']);
	
		if($length)
		{
			for($i=0;$i<$length;$i++)
			{
				$Products[] = new Product($db, $_SESSION['cart']['pr_id'][$i]);
			}
			
			createNewOrder($db, $Products, $user->id);
			
			echo'	<!-- Text -->
			<div class="twelve columns"></br>
			<legend>You can now retrieve your order in your <a href="account.php?sub=orders">account manager</a>! <i class="fa fa-check-circle-o"></i></legend>
			</div>
			';
		}
	}
	
	echo'	</div>
		</div>
		<div class="pad25"></div>';
	
			
include_once('inc/footer.php'); ?>